<template>
  <div style="margin-top: 20px">
    <el-card class="box-card21">
      <div class="clearfix">
        <span style="font-size: 1.5em; font-weight: bold; margin-left: 10px">{{ tablelist[0].topic }}</span>
        <div style="float: right">
          <el-button type="danger" size="small" style="margin-left: 10px">导出</el-button>
          <el-button type="danger" size="small" style="margin-left: 10px">打印</el-button>
        </div>
      </div>
      <div class="status" style="float: right; margin-right: 20px">
        <svg-icon icon-class="yiwan" style="width: 110px; height: 100px" />
      </div>
      <div style="margin-top: 40px">
        <div style="margin-left: 10px">创建人：{{ tablelist[0].createdBy }}</div>
        <div style="margin-top: 25px; margin-left: 10px">
          创建时间：{{ tablelist[0].creationTime }}
        </div>
      </div>
      <el-tabs style="margin-top: 50px">
        <el-tab-pane label="采购信息">
          <el-card>
            <div slot="header" class="clearfix">
              <span>基本信息</span>
            </div>
            <el-row :gutter="20" style="line-height: 3; margin-left: 90px; margin-right: -230px">
              <el-col :span="12">
                <div>验收单号：{{ tablelist[0].code }}</div>
                <div>验收日期：{{ tablelist[0].date }}</div>
                <div>验收人员：{{ tablelist[0].acceptor }}</div>
                <div>备注{{ tablelist[0].remark }}</div>
              </el-col>
              <el-col :span="12">
                <div>验收主题：{{ tablelist[0].topic }}</div>
                <div>验收部门：{{ tablelist[0].department }}</div>
                <div>采购单号：{{ tablelist[0].purchase }}</div>
              </el-col>
            </el-row>
          </el-card>
          <!--关联文件-->
          <el-card style="margin-top: 20px">
            <div slot="header" class="clearfix">
              <span>关联文档</span>
              <el-button style="float: right" type="primary" size="small">批量下载</el-button>
            </div>
            <el-table :data="tableData2" style="width: 100%">
              <el-table-column type="selection" width="55" align="center"></el-table-column>
              <el-table-column prop="index" label="序号" width="55" align="center">
                <template slot-scope="scope">
                  {{ scope.$index + 1 }}
                </template>
              </el-table-column>
              <el-table-column prop="filename" label="文件名" align="center"></el-table-column>
              <el-table-column prop="uploadTime" label="上传时间" align="center"></el-table-column>
              <el-table-column prop="uploader" label="上传者" align="center"></el-table-column>
              <el-table-column prop="size" label="文档大小" align="center"></el-table-column>
              <el-table-column label="操作" width="80" align="center">
                <template slot-scope="scope">
                  <el-button type="text" size="small" @click="downloadFile(scope.row)">下载</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-card>
          <div style="height: 100px"></div>
        </el-tab-pane>

        <el-tab-pane label="设备明细">
          <el-card>
            <div slot="header" class="clearfix">
              <span>设备明细</span>
            </div>
            <div>
              <el-button style="margin-bottom: 10px">导出</el-button>
              <el-table :data="tableData" style="width: 100%">
                <el-table-column type="selection" width="55"></el-table-column>
                <el-table-column prop="index" label="序号" width="60">
                  <template slot-scope="scope">
                    {{ scope.$index + 1 }}
                  </template>
                </el-table-column>
                <el-table-column label="操作" width="80">
                  <template #default="scope">
                    <el-link type="primary" v-if="scope.row.index !== 2">加入档案</el-link>
                  </template>
                </el-table-column>
                <el-table-column prop="state" label="状态" align="center"></el-table-column>
                <el-table-column prop="examine" label="验收结果" align="center"></el-table-column>
                <el-table-column prop="actual" label="购买数量" align="center"></el-table-column>
                <el-table-column prop="daohuo" label="已到货数量" width="100" align="center"></el-table-column>
                <el-table-column prop="benci" label="本次到货数量" width="100" align="center"></el-table-column>
                <el-table-column prop="numbering" label="设备编号" align="center"></el-table-column>
                <el-table-column prop="name" label="设备名称" align="center"></el-table-column>
                <el-table-column prop="model" label="规格型号" align="center"></el-table-column>
                <el-table-column prop="type" label="设备类型" align="center"></el-table-column>
                <el-table-column prop="manufacture" label="制造国别" align="center"></el-table-column>
                <el-table-column prop="manufacturer" label="生产厂家" align="center"></el-table-column>
                <el-table-column prop="brand" label="品牌" align="center"></el-table-column>
                <el-table-column prop="dateofManufacture" label="出厂日期" align="center"></el-table-column>
                <el-table-column prop="factoryNumber" label="出厂编号" align="center"></el-table-column>
                <el-table-column prop="weight" label="重量(吨)" align="center"></el-table-column>
                <el-table-column prop="reference" label="采购单价" align="center"></el-table-column>
                <el-table-column prop="quantity" label="购买数量" align="center"></el-table-column>
                <el-table-column prop="estimate" label="金额" align="center"></el-table-column>
                <el-table-column prop="useDepartments" label="使用部门" align="center"></el-table-column>
                <el-table-column prop="theEquipment" label="设备负责人" width="100" align="center"></el-table-column>
                <el-table-column prop="qingk" label="验收情况" align="center"></el-table-column>
                <el-table-column prop="remark" label="备注" align="center"></el-table-column>
                <el-table-column label="随附附件" align="center">
                  <template slot-scope="scope">
                    <el-button type="text" size="small" @click="downloadFile(scope.row)">查看</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <div class="summary">
                本次到货数量：<b>{{ totalCurrentQuantity }}</b>
              </div>
            </div>
          </el-card>
        </el-tab-pane>
        <!-- <el-tab-pane label="操作记录">
          <el-card>
            <div slot="header" class="clearfix">
              <span>操作记录</span>
            </div>
            <div>
              <el-button style="margin-bottom: 10px">导出</el-button>
              <el-table :data="tableData5" style="width: 100%">
                <el-table-column type="selection" width="55"></el-table-column>
                <el-table-column prop="index" label="序号" width="60"></el-table-column>
                <el-table-column prop="operator" label="操作人"></el-table-column>
                <el-table-column prop="time" label="操作时间"></el-table-column>
                <el-table-column prop="content" label="操作内容"></el-table-column>
              </el-table>
              <el-pagination background layout="prev, pager, next, sizes, total" :total="45" :page-size="10"
                style="margin-top: 20px; text-align: right">
              </el-pagination>
            </div>
          </el-card>
        </el-tab-pane> -->
      </el-tabs>
    </el-card>
  </div>
</template>

<script>
import { SelectAcceptanceList } from "@/api/eastjet-maintenance/caig/cai"
export default {
  data() {
    return {
      tableData: [],
      tablelist: [],
      //操作记录
      tableData5: [],
      //到货验收
      tableData32: [],
      //关联文件
      tableData2: [],
      form: {
        code: this.$route.query.code,
        purchase: this.$route.query.purchase,
      },
    };
  },
  computed: {
    totalCurrentQuantity() {
      return this.tableData.reduce(
        (sum, item) => sum + item.benci,
        0
      );
    },
    totalQuantity() {
      return this.tableData.reduce((sum, item) => sum + item.quantity, 0);
    },
    totalAmount() {
      return this.tableData.reduce((sum, item) => sum + item.total, 0);
    },
  },
  created() {
    this.getlist()
  },
  methods: {
    getlist() {
      SelectAcceptanceList(this.form).then((res) => {
        console.log("数据", res)
        this.tablelist = res.data.data.list
        this.tableData2 = res.data.data.documentations
        this.tableData = res.data.data.list1
      })
    }
  },
};
</script>

<style scoped>
.box-card21 {
  width: 1254px;
  /* height: 4010px; */
  margin-left: 30px;
}

.summary {
  margin-top: 10px;
  text-align: right;
}
</style>
